<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // var removeElement = function (nums, val) {
    //     let count = 0
    //     for (let i = 0; i < nums.length; i++) {
    //         if (nums[i] != val) {
    //             nums[count++] = nums[i]
    //             console.log(nums);



    //         }
    //     }
    //     return count
    // };
    // console.log(removeElement([0, 1, 2, 2, 3, 0, 4, 2], 2));

    x = (nums, val) => {
       for (var i=0;i<nums.length;i++){
        if(nums[i]==val){
            nums.splice(i,1)
            i--
        }

       }
       console.log(nums);
       
       return nums.length
    
    
    }
   
    
   console.log(x([1,2,3,4,5,4,4],4));
   
</script>

</html>